package sanrenxing.dayEnd.backRepertoryTotal.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sanrenxing.dayEnd.backRepertoryTotal.domain.TrusteeSetup;
import sanrenxing.dayEnd.backRepertoryTotal.service.impl.TrusteeSetupBizImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能：托管人控制器类
 * 编写者：蒋玲苹
 * 日期：
 * 版本：1.0
 */
@RestController
@RequestMapping("/trustee")
public class TrusteeSetupController {
    /*定义业务层接口*/
    @Autowired
    private TrusteeSetupBizImpl trusteeSetupBiz;

    @GetMapping("/tru")
    public Map<String,Object> queryAll(int page, int limit, TrusteeSetup trusteeSetup){
        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",trusteeSetupBiz.count(trusteeSetup));
        map.put("data",trusteeSetupBiz.queryAll(trusteeSetup,limit,(page-1)*limit));
        return map;
    }
    //添加数据
    @PostMapping("/tru")
    public String addTrusteeSetup(@RequestBody TrusteeSetup trusteeSetup) {
        int rows=trusteeSetupBiz.add(trusteeSetup);
        return rows>0?"add success":"failure";
    }

    //删除数据
    @DeleteMapping("/tru/{str}")
    public String deleteTrusteeSetup(@PathVariable String str){
        //调用业务层删除数据
        int rows=trusteeSetupBiz.delete(str);
        return rows>0?"delete success":"delete failure";
    }
    //修改数据
    @PutMapping("/tru")
    public String updateTrusteeSetup(@RequestBody TrusteeSetup trusteeSetup){
        //调用业务层修改数据
        int rows=trusteeSetupBiz.update(trusteeSetup);
        return rows>0?"update success":"update failure";
    }
}